package minecraft.xiyu.exchantedbook.procedures;

import minecraft.xiyu.exchantedbook.init.ExchantedBookModEnchantments;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;

public class NtptsProcedure {
	public static void execute(LivingEntity entity) {
		if (entity == null) return;

		ItemStack chestItem = entity.getItemBySlot(EquipmentSlot.CHEST);
		int ntptLevel = EnchantmentHelper.getItemEnchantmentLevel(ExchantedBookModEnchantments.NTPT.get(), chestItem);

		if (ntptLevel > 0) {
			int effectLevel = ntptLevel - 1;
			effectLevel = Math.min(effectLevel, 2);
			entity.addEffect(new MobEffectInstance(MobEffects.HARM, 20, effectLevel));
		}
	}
}